package com.fingard.dsp.bank.reqrespobj.contract;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.contract.detail.RetAtsContractDetail;
import com.fingard.xml.XmlTextWriter;

public class RetAtsQryBatContract extends RetAtsBase {
    public String respCode;
    public String respInfo;
    public RetAtsContractDetail retDetail;
    private boolean hasWrittenBefore = false;

    public RetAtsQryBatContract(ReqRespHeader p_header){
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();
    }

    public void writeBeforeDetail() throws Exception {
        if (hasWrittenBefore) {
            throw new Exception("writeBeforeDetail已被调用过");
        }
        writeStart();
        retXmlWriter.writeElementString("RespCode", respCode);
        retXmlWriter.writeElementString("RespInfo", respInfo);
        hasWrittenBefore = true;
    }

    public void writeAfterDetail() throws Exception {
        if (!hasWrittenBefore) {
            writeBeforeDetail();
        }
        writeEnd();// 写结束
    }

    public int writeRdCount = 0;
    public void writeRetDetail(RetAtsContractDetail p_retDetail) throws Exception {
        writeRdCount++;
        if (!hasWrittenBefore) {
            writeBeforeDetail();
        }
        retXmlWriter.writeStartElement("DetailRecord");
        retXmlWriter.writeElementString("PayAct", p_retDetail.payAct);
        retXmlWriter.writeElementString("SignState", p_retDetail.signState);
        retXmlWriter.writeElementString("SignMsg", p_retDetail.signMsg);
        retXmlWriter.writeElementString("AuthCode", p_retDetail.authCode);
        retXmlWriter.writeElementString("PayName", p_retDetail.payName);
        retXmlWriter.writeElementString("CellPhone", p_retDetail.cellPhone);
        retXmlWriter.writeElementString("CertType", p_retDetail.certType);
        retXmlWriter.writeElementString("CertNum", p_retDetail.certNum);
        retXmlWriter.writeEndElement();
    }
}
